// JavaScript Document

$(function(){
	$('#conteudo').hide();
	var noticia;	
	var hash = window.location.hash;
	if (hash !='')
	{
		noticia = $(hash).html();
		$('.abas li a[href="' + hash + '"]').parent().addClass('ativo');		
	} else {
		noticia = $('#conteudo div:first-child').html();			
		$('.abas li:first-child').addClass('ativo');		
	}
	$('#noticia').append('<div>' + noticia + '</div>').find('div').slideDown();
	
	$(document).ready(function(){
		$("#accordion").addClass("ui-accordion ui-widget ui-helper-reset ui-accordion-icons")
			.find("h3").addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom")
		.prepend('<span class="ui-icon ui-icon-triangle-1-e"/>')
		.click(function() {
			$(this).toggleClass("ui-accordion-header-active").toggleClass("ui-state-active")
				.toggleClass("ui-state-default").toggleClass("ui-corner-bottom")
			.find("> .ui-icon").toggleClass("ui-icon-triangle-1-e").toggleClass("ui-icon-triangle-1-s")
			.end().next().toggleClass("ui-accordion-content-active").toggle('slow');
			return false;
		})
		.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom").hide();
	})
	$('.abas li a').click(function(){
		$('.abas li').removeClass('ativo');
		$(this).parent().addClass('ativo');
		var ancora = $(this).attr('href');
		var nome = ancora.substr(1, ancora.length);
		noticia = $('#conteudo div[id="' + nome + '"]').html();
		$('#noticia').empty();
		$('#noticia').append('<div>' + noticia + '</div>').find('div').slideDown();
		
		$(document).ready(function(){
			$("#accordion").addClass("ui-accordion ui-widget ui-helper-reset ui-accordion-icons")
				.find("h3").addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom")
			.prepend('<span class="ui-icon ui-icon-triangle-1-e"/>')
			.click(function() {
				$(this).toggleClass("ui-accordion-header-active").toggleClass("ui-state-active")
					.toggleClass("ui-state-default").toggleClass("ui-corner-bottom")
				.find("> .ui-icon").toggleClass("ui-icon-triangle-1-e").toggleClass("ui-icon-triangle-1-s")
				.end().next().toggleClass("ui-accordion-content-active").toggle('slow');
				return false;
			})
			.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom").hide();
		})
	//return false();
	})
})